	
	cap log close

*******************************************************************
/* title: eodb_replication_robustness_1_coup_activity_2_polity_social_oecd.do */
/* description: replicating analysis from economic origins of dictatorship and democracy */
/* authors: dan slater, ben smith, gautam nair */
*******************************************************************

	clear
	set mem 500m
	set more off
	pause on 
	vers 10.0

*******************************************************************
* SET DIRECTORY & USE DATASET
*******************************************************************

	* set directory to folder containing replication data
	* cd " "
	use "eodb_replication_data.dta"

*******************************************************************
*  POLITY DEMOCRACY CUTOFF OF 4 INSTEAD OF CGV DEMOCRACY
*******************************************************************

	eststo clear

	* defining controls
	# delimit ;
	local controls_all 
	am_inc_gdp_ratio_l1
	wdi_ny_gdp_mktp_kd_zg_l1
	pwt_lngdppc_l1 
	pwt_kg_l1
	undp_manufacturing_share_l1 
	wdi_ny_gdp_totl_rt_zs_l1 
	wdi_log_population_l1 
	wdi_sp_pop_dpnd_ol_l1 
	pwt_openk_l1
	region_democ_polity2_4
	coup_success_yrs_free_l1 
	time_trend_linear_l1 
	time_trend_quadratic_l1 
	time_trend_cubic_l1
	;
	# delimit cr
	
	* full sample: coup success + regime transition
	eststo: nbreg coup_success_gwf `controls_all' if polity2_4_l1==1, cluster(ccode) iterate(50) irr
	* full sample: coup success
	eststo: nbreg coup_success_n `controls_all' if polity2_4_l1==1, cluster(ccode) iterate(50) irr
	* full sample: coup attempt
	eststo: nbreg coup_attempt_n `controls_all' if polity2_4_l1==1, cluster(ccode) iterate(50) irr
	* full sample: coup plots + rumors
	eststo: nbreg coup_plot_rumor_n `controls_all' if polity2_4_l1==1, cluster(ccode) iterate(50) irr

	* estout using "eodb_replication_robustness_1_coup_activity_2_polity_social_oecd_1_polity.xls", replace cells(b(fmt(%9.3f) star) se(par(`"="("' `")""') fmt(3)) ) stats(N N_clust, fmt(0 0)) style(tab) starlevels(* 0.10 ** 0.05 *** 0.01)  eform
	* estout using "eodb_replication_robustness_1_coup_activity_2_polity_social_oecd_1_polity_pvals.xls", replace cells(b(fmt(%9.3f) star) se(par(`"="("' `")""') fmt(3)) p(fmt(3)) ) stats(N N_g, fmt(0 0)) style(tab) starlevels(* 0.10 ** 0.05 *** 0.01)

*******************************************************************
*  EXCLUDING OECD COUNTRY YEARS
*******************************************************************

	eststo clear

	* defining controls
	# delimit ;
	local controls_all 
	am_inc_gdp_ratio_l1
	wdi_ny_gdp_mktp_kd_zg_l1
	pwt_lngdppc_l1 
	pwt_kg_l1
	undp_manufacturing_share_l1 
	wdi_ny_gdp_totl_rt_zs_l1 
	wdi_log_population_l1 
	wdi_sp_pop_dpnd_ol_l1 
	pwt_openk_l1
	region_democ_cgv_gwf_l1
	coup_success_yrs_free_l1 
	time_trend_linear_l1 
	time_trend_quadratic_l1 
	time_trend_cubic_l1
	;
	# delimit cr
	
	* full sample: coup success + regime transition
	eststo: nbreg coup_success_gwf `controls_all' if oecd_member!=1, cluster(ccode) iterate(50) irr
	* full sample: coup success
	eststo: nbreg coup_success_n `controls_all' if oecd_member!=1, cluster(ccode) iterate(50) irr
	* full sample: coup attempt
	eststo: nbreg coup_attempt_n `controls_all' if oecd_member!=1, cluster(ccode) iterate(50) irr
	* full sample: coup plots + rumors
	eststo: nbreg coup_plot_rumor_n `controls_all' if oecd_member!=1, cluster(ccode) iterate(50) irr

	* estout using "eodb_replication_robustness_1_coup_activity_2_polity_social_oecd_2_oecd.xls", replace cells(b(fmt(%9.3f) star) se(par(`"="("' `")""') fmt(3)) ) stats(N N_clust, fmt(0 0)) style(tab) starlevels(* 0.10 ** 0.05 *** 0.01)  eform
	* estout using "eodb_replication_robustness_1_coup_activity_2_polity_social_oecd_2_oecd_pvals.xls", replace cells(b(fmt(%9.3f) star) se(par(`"="("' `")""') fmt(3)) p(fmt(3)) ) stats(N N_g, fmt(0 0)) style(tab) starlevels(* 0.10 ** 0.05 *** 0.01)

*******************************************************************
*  SOCIAL SPENDING INSTEAD OF GOVERNMENT SHARE OF GDP
*******************************************************************

	eststo clear

	* defining controls
	# delimit ;
	local controls_all 
	am_inc_gdp_ratio_l1
	wdi_ny_gdp_mktp_kd_zg_l1
	pwt_lngdppc_l1 
	am_social_spend_gdp_l1
	undp_manufacturing_share_l1 
	wdi_ny_gdp_totl_rt_zs_l1 
	wdi_log_population
	wdi_sp_pop_dpnd_ol_l1 
	pwt_openk_l1
	region_democ_cgv_gwf_l1
	coup_success_yrs_free_l1 
	time_trend_linear_l1 
	time_trend_quadratic_l1 
	time_trend_cubic_l1
	;
	# delimit cr

	* full sample: coup success + regime transition
	eststo: nbreg coup_success_gwf `controls_all', cluster(ccode) iterate(50) irr
	* full sample: coup success
	eststo: nbreg coup_success_n `controls_all', cluster(ccode) iterate(50) irr
	* full sample: coup success
	eststo: nbreg coup_success `controls_all', cluster(ccode) iterate(50) irr
	* full sample: coup attempt
	eststo: nbreg coup_attempt_n `controls_all', cluster(ccode) iterate(50) irr
	* full sample: coup plots + rumors
	eststo: nbreg coup_plot_rumor_n `controls_all', cluster(ccode) iterate(50) irr

	* estout using "eodb_replication_robustness_1_coup_activity_2_polity_social_oecd_3_socialspending.xls", replace cells(b(fmt(%9.3f) star) se(par(`"="("' `")""') fmt(3)) ) stats(N N_clust, fmt(0 0)) style(tab) starlevels(* 0.10 ** 0.05 *** 0.01)  eform
	* estout using "eodb_replication_robustness_1_coup_activity_2_polity_social_oecd_3_socialspending_pvals.xls", replace cells(b(fmt(%9.3f) star) se(par(`"="("' `")""') fmt(3)) p(fmt(3)) ) stats(N N_g, fmt(0 0)) style(tab) starlevels(* 0.10 ** 0.05 *** 0.01)

*******************************************************************
* LOG CLOSE
*******************************************************************
	
	* log close

